package com.eistert.java.datastructure._13_UnionFind;

import java.util.Random;

public class _13_Main {

    private static double testUF(_13_UF a13Uf, int m) {

        int size = a13Uf.getSize();
        Random random = new Random();

        long startTime = System.nanoTime();


        for (int i = 0; i < m; i++) {
            int a = random.nextInt(size);
            int b = random.nextInt(size);
            a13Uf.unionElements(a, b);
        }

        for (int i = 0; i < m; i++) {
            int a = random.nextInt(size);
            int b = random.nextInt(size);
            a13Uf.isConnected(a, b);
        }

        long endTime = System.nanoTime();

        double time = (endTime - startTime) / 1000000000.0;
        return time;
    }

    public static void main(String[] args) {

        int size = 10000000;
        int m = 10000000;

//        UnionFind1 uf1 = new UnionFind1(size);
//        System.out.println("UnionFind1 : " + testUF(uf1, m) + " s");
//
//        UnionFind2 uf2 = new UnionFind2(size);
//        System.out.println("UnionFind2 : " + testUF(uf2, m) + " s");

        _13_UnionFind3 uf3 = new _13_UnionFind3(size);
        System.out.println("UnionFind3 : " + testUF(uf3, m) + " s");

        _13_UnionFind4 uf4 = new _13_UnionFind4(size);
        System.out.println("UnionFind4 : " + testUF(uf4, m) + " s");

        _13_UnionFind5 uf5 = new _13_UnionFind5(size);
        System.out.println("UnionFind5 : " + testUF(uf5, m) + " s");

        _13_UnionFind6 uf6 = new _13_UnionFind6(size);
        System.out.println("UnionFind6 : " + testUF(uf6, m) + " s");
    }
}
